package com.yejiali.backend.controller;

import com.yejiali.backend.response.Response;
import com.yejiali.backend.service.OssService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author:yejiali
 * @Date:2025/7/21-07-21-17:58
 * @Decsription:com.yejiali.backend.controller
 * @Version:1.0
 */
@RestController
@RequestMapping("/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    /**
     * 上传视频到oss
     * @param file
     * @param userId
     * @return
     */
    @PostMapping("/upload/video")
    public Response<String>  uploadVideo(@RequestParam("video") MultipartFile file, @RequestParam("userId") Long userId) {
        return ossService.saveVideo(file,userId);
    }

    /**
     * 上传视频封面图
     * @param file
     * @param userId
     * @return
     */
    @PostMapping("/upload/picture")
    public Response<String> uploadPicture(@RequestParam("picture") MultipartFile file, @RequestParam("userId") Long userId) {
        return ossService.savePicture(file, userId);
    }

}
